/**
 * Copyright (c) Software Institute of PKU
 * All rights reserved. 
 * This program and the accompanying materials
 * are made available under the terms of the Eclipse Public License v1.0
 * which accompanies this distribution, and is available at
 * http://www.eclipse.org/legal/epl-v10.html
 *
 */
package edu.pku.sei.transformation.editor.views.figures;

import org.eclipse.draw2d.ColorConstants;
import org.eclipse.draw2d.Figure;
import org.eclipse.draw2d.Label;
import org.eclipse.draw2d.LineBorder;
import org.eclipse.draw2d.ToolbarLayout;
import org.eclipse.draw2d.XYLayout;
import org.eclipse.draw2d.geometry.Point;
import org.eclipse.draw2d.geometry.Rectangle;
import org.eclipse.swt.graphics.Color;

import edu.pku.sei.modeler.figures.CommonFigure;

/**
 * @generated
 * 
 */
public class CollectionTemplateFigure extends CommonFigure implements
		ITemplateFigure {
	private Color foregroundColor = ColorConstants.black;
	private Color backgroundColor = ColorConstants.white;

	private Figure frontFigure = new Figure();
	private Figure backFigure = new Figure();
	private Label name = new Label();

	public CollectionTemplateFigure() {

		this.setLayoutManager(new XYLayout());

		frontFigure.setBackgroundColor(this.backgroundColor);
		frontFigure.setSize(this.getSize().width - 10,
				this.getSize().height - 10);
		frontFigure.setLocation(new Point(this.getLocation().x, this
				.getLocation().y + 10));
		frontFigure.setBorder(new LineBorder(ColorConstants.buttonDarker, 1));
		frontFigure.setOpaque(true);

		backFigure.setBackgroundColor(this.backgroundColor);
		backFigure.setSize(this.getSize().width - 10,
				this.getSize().height - 10);
		backFigure.setLocation(new Point(this.getLocation().x + 10, this
				.getLocation().y));
		backFigure.setBorder(new LineBorder(ColorConstants.buttonDarker, 1));
		backFigure.setOpaque(true);
		this.add(backFigure);
		this.add(frontFigure);

		frontFigure.setLayoutManager(new ToolbarLayout());
		name.setText("name");
		frontFigure.add(name);

	}

	public void setBounds(Rectangle rect) {
		super.setBounds(rect);
		frontFigure.setBounds(new Rectangle(rect.x, rect.y + 10,
				rect.width - 10, rect.height - 10));
		backFigure.setBounds(new Rectangle(rect.x + 10, rect.y,
				rect.width - 10, rect.height - 10));
	}

	public void setHeadText(String text) {
		name.setText(text);
	}

	@Override
	public Label getNameLabel() {
		return this.name;

	}

}
